#!/usr/bin/env python

import sys
from itertools import groupby

def parse_source(source):
    for line in source:
        gene_func_stricted, cnt, gene_func = line.strip('\n').split('\t')
        yield (gene_func_stricted, int(cnt), gene_func)

def main():
    for gene_func_stricted, grp in groupby(parse_source(sys.stdin), key=lambda i:i[0]):
        master_gene_func = sorted((i[1], i[2]) for i in grp)[-1][1]
        print '%s\t%s' % (gene_func_stricted, master_gene_func)
    

if __name__ == "__main__":
    main()

